package com;

import java.util.Random;

public class Demo2 {
	public static void main(String[] args) {
		int a[] = new int[10];
		generateRand(a);
		out(a);
		sum(a);
		findmax(a);
		findmin(a);
		System.out.println("和为："+sum(a)+"最大值为：" + findmax(a) + "最小值为：" + findmin(a));
	}

	public static void generateRand(int[] a) {
		Random rd = new Random();
		for (int i = 0; i < a.length; i++) {
			a[i] = rd.nextInt(100);
		}
	}

	public static int findmax(int[] a) {
		int max = a[0];
		for (int i = 0; i < a.length; i++)
			if (a[i] > max)
				max = a[i];
		return max;
	}

	private static void out(int[] a) {
		for (int i = 0; i < a.length; i++)
			System.out.print(a[i]+"  "); 

	}

	public static int findmin(int[] a) {
		int min = a[0];
		for (int i = 0; i < a.length; i++)
			if (a[i] < min)
				min = a[i];
		return min;
	}
	public static int sum(int[] a){
		int s=0;
		for(int i=0;i<a.length;i++)
			s=s+a[i];
		    return s;
}
}